<template>
	<div class="addApplication">
		<van-nav-bar title="技改申请" left-arrow="" @click-left='goBack()'>
			<van-button @click='goApplicationInfo' type="primary" slot='right' color="#62cff9">技改详情</van-button>
		</van-nav-bar>
		<van-field v-model="name" :clearable="true" :border="false" label="技改名称" placeholder="请输入技改名称"></van-field>
		<!-- <van-field :clearable="true" label="技改单号" placeholder="请输入技改单号"></van-field>
		 -->
		<van-field v-model="content" rows="3" :clearable="true" autosize label="技改内容" type="textarea" maxlength="50" placeholder="请输入技改内容"
		 show-word-limit />
		 <div class="btn">
		 	<van-button color="#62cff9" type="default" size="large" @click='saveSuccess'>保存</van-button>
		 </div>
	</div>
</template>

<script>
	import {Toast} from 'vant'
	let moment = require('moment')
	export default{
		data(){
			return{
					content:'',
					userName:'',
					name:''
			}
		},
		created(){
			
		},
		methods:{
			saveSuccess(){
				let newTime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
				newTime.trim()
				let id = newTime.replace(/[\s|\~|`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g,"");
				id = id.substring(0,14)
				id = 'JG'+id
				this.$axios.post('Renovation/addRenovation.do',{id:id,applyDate:newTime,applyusername:JSON.parse(localStorage.cksLoginInfo).userName,content:this.content,name:this.name}).then(res=>{
					if(res.data.status === 200){
							Toast.success({message:'添加成功',duration:900})
							setTimeout(()=>{
								this.$router.push({name:'changeApplication'})
							},900)
					}else{
						Toast.fail({message:'添加失败',duration:900})
					}
				})
			},
			goApplicationInfo(){
				this.$router.push({name:'changeApplication'})
			}
		}
	}
</script>

<style scoped="scoped">
	.van-cell{
		border-bottom: 1px solid #EEEEEE;
	}
	.van-button {
		border-radius: 7px;
		height: 1.8rem;
		line-height: 1.8rem;
		font-size: .8rem;
		padding-left: .4rem;
		padding-right: .4rem;
	}
	.van-button--large {
		height: 2.3rem;
		line-height: 2.3rem;
	}
	
	.btn {
		padding: .8rem;
	}
</style>
